import { APIResult } from '@/requestErrorConfig';
import myRequest from './index';

export const login = (data: any) => {
  return myRequest<
    APIResult<{
      username: string;
      token: string;
      login_time: string;
    }>
  >(
    '/admin_api/login/admin/by_password',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data,
    },
    false,
  );
};

export const getCaptchaCodeApi = () => {
  return myRequest<{
    captcha: string;
    uuid: string;
  }>(
    '/api/captcha/generate',
    {
      headers: {
        'Content-Type': 'application/json',
      },
    },
    false,
  );
};

export interface IUser {
  id: number;
  username: string;
  realname: string;
  group_id: string;
  mobile: string;
  remark: string;
  status: number;
  create_time: string;
  update_time: string;
  group_status: string;
  group_name: string;
  group_arr: number[];
  email: string;
}

export const getUserCommunicateApi = (data: any) => {
  return myRequest<any>('/admin_api/user_communication_log/list', {
    method: 'POST',
    data,
  });
};

export const addCommunicateApi = (data: any) => {
  return myRequest<any>('/admin_api/user_communication_log/add', {
    method: 'POST',
    data,
  });
};

export const editCommunicateApi = (data: any) => {
  return myRequest<any>('/admin_api/user_communication_log/edit', {
    method: 'POST',
    data,
  });
};

export const deleteCommunicateApi = (id: string) => {
  return myRequest<any>(`/admin_api/user_communication_log/${id}`, {
    method: 'DELETE',
  });
};
